<?php

declare(strict_types=1);

namespace App\Process\Logger;


use Hyperf\Context\Context;

class RequestIdProcessor extends \Monolog\Processor\MemoryUsageProcessor
{
    /**
     * {@inheritDoc}
     */
    public function __invoke(array $record): array
    {
        if (!Context::has('request_id')) {
            return $record;
        }
        $requestId = Context::get('request_id');

        $record['extra']['request_id'] = $requestId;

        return $record;
    }
}
